library(raster)

##批量读入后缀名为.ncd的文件
data.dsn.list<-list.files(path = 'data',pattern = '.nc$',recursive = T,full.names = T)

##用循环实现批量.nc转化.tif，再自动写出.tif文件
for (i in 1:length(data.dsn.list)){
  rast<-raster(data.dsn.list[i])   
  writeRaster(rast, filename=paste(i,".tif"), format="GTiff",overwrite=TRUE)  
}
